//  this library.
import 'package:hktk_app/ienum/subject/paper_type_enum.dart';

/// 试卷相关模型
class PaperModel {
  // 学科id
  int? categoryId;
  String? name;
  String? serverName;

  // 试卷备注
  String? remark;

  // 完整度
  int? integrityState;

  // 所属年份
  String? sourceYear;

  // 考试时长
  int? examTime;

  // 总分
  int? totalScore;

  // 及格分
  int? passScore;

  // 所属区域
  String? region;

  // 来源id
  String? sourceId;

  // 资料类型
  int? sourceType;

  // 试卷类型
  PaperTypeEnum? paperType;

  // 学习人数
  int? stuCount;

  // 是否隐藏试卷
  bool? isHide;

  // 排序
  int? sort;

  // 试题数量
  int? qcount;

  // 查看次数
  int? watchTime;

  // 高教题库id
  int? highEduId;

  // 考试id
  String? examId;

  // 考试名
  String? examName;

  // 行业id
  String? industryId;

  // 行业名
  String? industryName;

  // 考研科目id
  int? kaoyanCategoryId;

  // 旧科目id
  int? oldCategoryId;

  // 试题ids
  List<String>? questionIds;
  dynamic contentMap;

  // 学科名
  String? categoryName;

  // 学科名(旧)
  String? oldCategoryName;

  // 栏目id
  String? columnId;
  bool? free;
  String? id;

  bool? deleted;
  String? deleteTime;
  String? createdBy;
  String? modifyBy;
  String? createdTime;
  String? modifyTime;
  int? count;
  bool? working;
  String? recordId;

  PaperModel({
    this.categoryId,
    this.name,
    this.serverName,
    this.remark,
    this.integrityState,
    this.sourceYear,
    this.examTime,
    this.totalScore,
    this.passScore,
    this.region,
    this.sourceId,
    this.sourceType,
    this.paperType,
    this.stuCount,
    this.isHide,
    this.sort,
    this.qcount,
    this.watchTime,
    this.highEduId,
    this.examId,
    this.examName,
    this.industryId,
    this.industryName,
    this.kaoyanCategoryId,
    this.oldCategoryId,
    this.questionIds,
    this.contentMap,
    this.categoryName,
    this.oldCategoryName,
    this.columnId,
    this.free,
    this.id,
    this.deleted,
    this.deleteTime,
    this.createdBy,
    this.modifyBy,
    this.createdTime,
    this.modifyTime,
    this.count,
    this.working,
    this.recordId,
  });

  PaperModel.fromJson(Map<String, dynamic> json) {
    categoryId = json['categoryId'];
    name = json['name'];
    serverName = json['serverName'];
    remark = json['remark'];
    integrityState = json['integrityState'];
    sourceYear = json['sourceYear'];
    examTime = json['examTime'];
    totalScore = json['totalScore'];
    passScore = json['passScore'];
    region = json['region'];
    sourceId = json['sourceId'];
    sourceType = json['sourceType'];
    if (json["paperType"] != null) {
      paperType = _getTypeEnum(json["paperType"]);
    }
    stuCount = json['stuCount'];
    isHide = json['isHide'];
    sort = json['sort'];
    qcount = json['qcount'];
    watchTime = json['watchTime'];
    highEduId = json['highEduId'];
    examId = json['examId'];
    examName = json['examName'];
    industryId = json['industryId'];
    industryName = json['industryName'];
    kaoyanCategoryId = json['kaoyanCategoryId'];
    oldCategoryId = json['oldCategoryId'];
    if (json["questionIds"] != null) {
      questionIds = json['questionIds'].cast<String>();
    }
    contentMap = json["contentMap"];
    categoryName = json['categoryName'];
    oldCategoryName = json['oldCategoryName'];
    columnId = json['columnId'];
    free = json['free'];
    id = json['id'];
    deleted = json["deleted"];
    deleteTime = json["deleteTime"];
    createdBy = json['createdBy'];
    modifyBy = json['modifyBy'];
    createdTime = json['createdTime'];
    modifyTime = json['modifyTime'];
    count = json["count"];
    working = json["working"];
    recordId = json["recordId"];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    data['categoryId'] = categoryId;
    data['name'] = name;
    data['serverName'] = serverName;
    data['remark'] = remark;
    data['integrityState'] = integrityState;
    data['sourceYear'] = sourceYear;
    data['examTime'] = examTime;
    data['totalScore'] = totalScore;
    data['passScore'] = passScore;
    data['region'] = region;
    data['sourceId'] = sourceId;
    data['sourceType'] = sourceType;
    if (paperType != null) {
      data['paperType'] = paperType!.name;
    }
    data['stuCount'] = stuCount;
    data['isHide'] = isHide;
    data['sort'] = sort;
    data['qcount'] = qcount;
    data['watchTime'] = watchTime;
    data['highEduId'] = highEduId;
    data['examId'] = examId;
    data['examName'] = examName;
    data['industryId'] = industryId;
    data['industryName'] = industryName;
    data['kaoyanCategoryId'] = kaoyanCategoryId;
    data['oldCategoryId'] = oldCategoryId;
    data['questionIds'] = questionIds;
    data["contentMap"] = contentMap;
    data['categoryName'] = categoryName;
    data['oldCategoryName'] = oldCategoryName;
    data['columnId'] = columnId;
    data['free'] = free;
    data['id'] = id;
    data["deleted"] = deleted;
    data["deleteTime"] = deleteTime;
    data['createdBy'] = createdBy;
    data['modifyBy'] = modifyBy;
    data['createdTime'] = createdTime;
    data['modifyTime'] = modifyTime;
    data["count"] = count;
    data["working"] = working;
    data["recordId"] = recordId;
    return data;
  }

  /// 获取对应的枚举类型
  PaperTypeEnum _getTypeEnum(String type) {
    List<PaperTypeEnum> values = PaperTypeEnum.values;
    for (PaperTypeEnum typeEnum in values) {
      if (typeEnum.name == type) {
        return typeEnum;
      }
    }
    return PaperTypeEnum.mock;
  }
}
